import request from './request'
  //标准化时间
export function getFormatVideoTime(time) {
    let curtime = time
    let m = parseInt((curtime % 3600) / 60)
    let s = parseInt(curtime % 60)
    m = m < 10 ? '0' + m : m
    s = s < 10 ? '0' + s : s
    return  m + ':' + s
}
  // ===============================================================================================
  
//菜单数据-------------------------------------
export function getmenu(data) {
    return request.get('http://localhost:8080/static/testmenu.json',data)
  }
//诗歌数据
//所思
export function getpoetry(data) {
    return request.get('http://localhost:8080/static/TheThink.json',data)
  }
//所见
export function getpoetryLook(data) {
  return request.get('http://localhost:8080/static/TheLook.json',data)
}
//所想
export function getpoetryWant(data) {
  return request.get('http://localhost:8080/static/TheWant.json',data)
}
//vlogo
export function getvlogo(data) {
  return request.get('http://localhost:8080/static/vlogo.json',data)
}
//more
export function getmore(data) {
  return request.get('http://localhost:8080/static/more.json',data)
}

// ===============================================================================================
//页面懒加载
//滚动条在Y轴上的滚动距离
export function getScrollTop(){
  var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
  if(document.body){
    bodyScrollTop = document.body.scrollTop;
  }
  if(document.documentElement){
    documentScrollTop = document.documentElement.scrollTop;
  }
  scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
  return scrollTop;
}
//文档的总高度
export function getScrollHeight(){
  var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
  if(document.body){
    bodyScrollHeight = document.body.scrollHeight;
  }
  if(document.documentElement){
    documentScrollHeight = document.documentElement.scrollHeight;
  }
  scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
  return scrollHeight;
}
//浏览器视口的高度
export function getWindowHeight(){
  var windowHeight = 0;
  if(document.compatMode == "CSS1Compat"){
    windowHeight = document.documentElement.clientHeight;
  }else{
    windowHeight = document.body.clientHeight;
  }
  return windowHeight;
}
//数据切割
// export function cuttingdata(data){
//   let obj={};
//   let objkey=0;
//   let res=data;
//   toviewlist=this.toviewlist;
//   if(res.data.list.length>6){
//     for(let i = 0; i < Math.ceil(res.data.list.length / 6); i++){
//       obj[i]=res.data.list.slice(6*i,6*(i+1));
//     }  
//         this.toviewlist= obj[objkey];
//         console.log(this.toviewlist);
        
//   }else{
//     this.toviewlist=res.data.list; 
//   }
// }
/**
 * @description 登录 post提交
 */
export function login(data) {
  return request.post(`login`, data)
}

/**
 * @description 退出登录 get提交
 */
export function logout() {
  return request.get(`logout`)
}